<?php
/*------------------------------------------------------------------------
# com_vportfolio - Vportfolio component
# ------------------------------------------------------------------------
# author    Vsmart Extensions
# copyright Copyright (C) 2010 www.vsmart-extensions.com. All Rights Reserved.
# @license - http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
# Websites: http://www.vsmart-extensions.com
# Technical Support:  Forum - http://www.vsmart-extensions.com
-------------------------------------------------------------------------*/
// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );

/**
 * Renders a category Portpolio element 
 *
 * @package 	Joomla.Framework
 * @subpackage	Vportfolio
 * @since		1.5
 */

class JElementCategoryP extends JElement
{
	/**
	* Element name
	*
	* @access	protected
	* @var		string
	*/
	var	$_name = 'CategoryP';

	function fetchElement($name, $value, &$node, $control_name)
	{
		
		$db = &JFactory::getDBO();	
		
		$query = 'SELECT count(id)' .
				' FROM #__vportfolio_category' .
				' WHERE public = 1';
		$db->setQuery($query);
		$count = $db->loadResult() + 2;
		
		$query = 'SELECT id, name' .
				' FROM #__vportfolio_category' .
				' WHERE public = 1' .				
				' ORDER BY name';		
		$db->setQuery($query);
		$options = $db->loadObjectList();
		
		
		return JHTML::_('select.genericlist',  $options, ''.$control_name.'['.$name.'][]', ' multiple="multiple" size=" '.$count.'"', 'id', 'name', $value, $control_name.$name );
	}
}